<?php
namespace App\Admin\Models;
use Common\BaseModel;
class ArticleCategories extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function initialize()
    {
        parent::initialize();
        $this->setSource('f_article_categories');
    }


    /**
     * @return mixed 获取营销分类的标题
     */
    public function getlist(){
        $cate_list = $this::find(
        array(
            "order" => 'sort asc',
            "columns"=>'id,name,type,sort,created_at',
        ));
        return $cate_list;
    }



    /**
     * 根据id获取营销分类的名称
     */
    public function find_first_by_Id($id){
        if(empty($id)){
            return '';
        }
        $cate_info = $this->findFirstById($id);
        if($cate_info){
            return $cate_info->toarray();
        }else{
            return [];
        }

    }

    public function save_cate($params){
        $result = $this::save($params);
        if($result){
            return true;
        }else{
            return false;
        }
    }

}
